package com.tedu._06weibo.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor//让lombok生成全参构造器
@NoArgsConstructor//无参构造器
public class JsonResult {
    //状态码，用于告知前段当前业务处理的结果
    private Integer statusCode;
    //提示消息，用于让前段提示给用户使用
    private String message;
    //活肤给前段本次业务处理的数据（例如某个VO）
    private Object data;
    public JsonResult(Status status,Object data){
        this.statusCode=status.getStatusCode();
        this.message=status.getMaeesage();
        this.data=data;
    }
    public JsonResult(Status status){
        this.statusCode=status.getStatusCode();
        this.message=status.getMaeesage();
    }
    public static JsonResult success(){
        return new JsonResult(Status.OPERATION_SUCCESS);
    }
    public static JsonResult success(Object data){
        return new JsonResult(Status.OPERATION_SUCCESS,data);
    }
}
